﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyHealthByDesignWebsite.Models
{
    public class NutritionProfileRepository
    {
        //Description:  Repository for Nutrition Profile
        //Created:  Nov 2011
        //Programmer:  Bob Whiteis
        private FullDataSetDataContext db = new FullDataSetDataContext();
        //

        //pre-condition:  Nutrition Profile id has been supplied
        //post-condtion Nutrition Profile is returned
        public NutritionProfile GetNutritionProfile(int id)
        {
            return db.NutritionProfiles.SingleOrDefault(np => np.NP_nutritionProfileID == id);
        }
        //
        // Insert/Delete Methods
        //pre-condition:  Nutrition Profile has been supplied
        //post-condtion Nutrition Profile has been added
        public void Add(NutritionProfile nutritionProfile)
        {
            db.NutritionProfiles.InsertOnSubmit(nutritionProfile);
        }
        //pre-condition:  Nutrition Profile has been supplied
        //post-condtion Nutrition Profile has been deleted
        public void Delete(NutritionProfile nutritionProfile)
        {

            db.NutritionProfiles.DeleteOnSubmit(nutritionProfile);
        }
        //
        // Persistence
        public void Save()
        {
           
            db.SubmitChanges();
           
        }    
    }
}